package com.huanuo.internetofthings.service.fastPeriphery;

import com.huanuo.internetofthings.bo.fastPeriphery.FastPeriphery;
import com.huanuo.internetofthings.dao.fastPeriphery.FastPeripheryMapper;
import com.huanuo.internetofthings.dto.fastPeriphery.FastPeripheryPageRequestDto;
import org.springframework.stereotype.Service;
import org.unicorn.framework.base.base.AbstractService;
import org.unicorn.framework.core.exception.PendingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.unicorn.framework.core.SysCode;
import java.util.List;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
/**
 * <p>
 * fast周边网络情况 服务实现类
 * </p>
 *
 * @author xiebin
 * @since 2018-08-03
 */
@Service
public class FastPeripheryService extends AbstractService {
  @Autowired
  private FastPeripheryMapper fastPeripheryMapper;
  /**
     * 根据主键删除记录
     * @param id
     * @return
     * @throws PendingException
     */
  public void deleteByPrimaryKey(Long id) throws PendingException{
    try {
			 fastPeripheryMapper.deleteByPrimaryKey(id);
		} catch (Exception e) {
			error("删除记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "删除记录失败");
	}
    
  }


   /**
     * 保存记录
     * @param fastPeriphery
     * @return
     * @throws PendingException
     */
   public  FastPeriphery save(FastPeriphery fastPeriphery) throws PendingException{
       try {
			 fastPeripheryMapper.insertSelective(fastPeriphery);
			 return fastPeriphery;
		} catch (Exception e) {
			error("新增记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "新增记录失败");
	}
   }
      /**
     * 根据主键查询记录
     * @param id
     * @return
     * @throws PendingException
     */
    public FastPeriphery selectByPrimaryKey(Long id) throws PendingException{
    try {
			return fastPeripheryMapper.selectByPrimaryKey(id);
		} catch (Exception e) {
			error("查询记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "查询记录失败");
	}
    }
    
     /**
     * 根据条件查询记录列表
     * @param fastPeriphery
     * @return
     * @throws PendingException
     */
    public  List<FastPeriphery> selectList(FastPeriphery fastPeriphery) throws PendingException{
       try {
			return fastPeripheryMapper.selectList(fastPeriphery);
		} catch (Exception e) {
			error("查询列表失败", e);
			throw new PendingException(SysCode.DB_ERROR, "查询列表失败");
	}
    }
    
    /** 
	 * 分页查询fast周边网络情况信息
	 * 
	 * @param fastPeripheryPageRequestDto
	 * @return
	 * @throws PendingException
	 */
	public PageInfo<FastPeriphery> getFastPeripheryByPage(FastPeripheryPageRequestDto fastPeripheryPageRequestDto)
			throws PendingException {
		try {
			PageHelper.startPage(fastPeripheryPageRequestDto.getPageNo(),fastPeripheryPageRequestDto.getPageSize());
			List<FastPeriphery> list=fastPeripheryMapper.selectList(fastPeripheryPageRequestDto.getFastPeriphery());
			PageInfo<FastPeriphery> pageInfo = new PageInfo<>(list);
			return pageInfo;
		}catch (Exception e) {
			error("分页查询fast周边网络情况失败", e);
			throw new PendingException(SysCode.DB_ERROR, "分页查询fast周边网络情况失败");
		}
	}
    
    /**
     * 根据主键列表查询记录
     * @param ids
     * @return
     * @throws PendingException
     */
    public  List<FastPeriphery> selectListByIds(List<Long> ids) throws PendingException{
     try {
			return fastPeripheryMapper.selectListByIds(ids);
		} catch (Exception e) {
			error("根据ID列表批量查询记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "根据ID列表批量查询记录失败");
	}
    }
   /**
     * 根据条件查询一条记录
     * @param fastPeriphery
     * @return
     * @throws PendingException
     */
    public  FastPeriphery selectOne(FastPeriphery fastPeriphery) throws PendingException{
      try {
			return fastPeripheryMapper.selectOne(fastPeriphery);
		} catch (Exception e) {
			error("查询单条记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "查询单条记录失败");
	}
    }

    /**
     * 根据主键修改记录
     * @param fastPeriphery
     * @return
     * @throws PendingException
     */
    public FastPeriphery updateByPrimaryKey(FastPeriphery fastPeriphery) throws PendingException{
       try {
			 fastPeripheryMapper.updateByPrimaryKey(fastPeriphery);
			return fastPeriphery;
		} catch (Exception e) {
			error("根据主键更新单条记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "根据主键更新单条记录失败");
	}
    }
}
